#include "crc.h"

unsigned int CRC(unsigned int oldCRC, unsigned char ch)
{
	unsigned long crcPoly = 0x8005;
	
	unsigned char n;
	unsigned long m;

	m = ((unsigned long)oldCRC << 8) | ch;
	for (n = 0; n < 8; n++)
		if ((m <<= 1) & 0x1000000)
		{
			m ^= 0x800500; //(crcPoly << 8 );
		}

	return (unsigned int)(m >> 8);
}
